<!--  创建订单  -->
<template>
   <div class="page_rela_container">
    <div class="scroll_auto flex_cell">

    <el-form id="page_order_create" ref="form" :model="form" :rules="rules" v-loading="loading" label-position="right"
      label-width="200px" class="common-form-panel-div">
      <ex_header_spiler :title="$t('label_tms_waybill_order_info')">
      </ex_header_spiler>
      <el-row>
        <el-col>
          <el-form-item :label="$t('label_srm_api_order_no')">
            <ex_super_input v-model="form.trackNumber" disabled />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col>
          <el-form-item :label="$t('label_quick_select_address')">
            <quick_select_customer_address :customerId="form.customerId" @command="deliveryAddressSet" class="widthSet"/>

          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <!-- <el-col>
          <el-form-item :label="$t('label_customer_name')" prop="customerId">
            <common_customer_choose v-model="form.customerId"
               @changeItem="customerChange"
              style="width: 100%;"></common_customer_choose>
          </el-form-item>
        </el-col> -->
        <el-col>
          <el-form-item :label="$t('label_place_delivery')" prop="deliveryCountryCode">
            <cascader_address_select v-if="(form.id && form.deliveryCountryCode || !form.id) && !isHideDelivery" class="w_fill"
              :countryCode.sync="form.deliveryCountryCode" :countryName.sync="form.deliveryCountryName"
              :province.sync="form.deliveryProvinceName" :city.sync="form.deliveryCityName"
              :county.sync="form.deliveryAreaName" :zipCode.sync="form.deliveryPostalCode" :checkStrictly="false" />
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item :label="$t('label_tms_track_consigner_name')" prop="deliveryUserName">
            <ex_super_input v-model="form.deliveryUserName" />
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item :label="$t('label_tms_track_consigner_phone')" prop="deliveryContacts">
            <ex_super_input v-model="form.deliveryContacts" />
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item :label="$t('label_post_code')" prop="deliveryPostalCode">
            <ex_super_input v-model="form.deliveryPostalCode" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col>
          <el-form-item :label="$t('label_tms_waybill_dispatch_addr')" prop="deliveryAddress">
            <el-input type="textarea" v-model="form.deliveryAddress" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col>
          <el-form-item :label="$t('label_quick_select_address')">
            <quick_select_customer_address :customerId="form.customerId" @command="receiptAddressSet"  class="widthSet"/>

          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col>
          <el-form-item :label="$t('label_place_Receipt')" prop="receiptCountryCode">
            <cascader_address_select v-if="(form.id && form.receiptCountryCode || !form.id) && !isHideReceipt" class="w_fill"
              :countryCode.sync="form.receiptCountryCode" :countryName.sync="form.receiptCountryName"
              :province.sync="form.receiptProvinceName" :city.sync="form.receiptCityName"
              :county.sync="form.receiptAreaName" :zipCode.sync="form.receiptPostalCode" :checkStrictly="false" />
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item :label="$t('label_tms_track_consignee_name')" prop="receiptUserName">
            <ex_super_input v-model="form.receiptUserName" />
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item :label="$t('label_tms_waybill_consignee_contact')" prop="receiptContacts">
            <ex_super_input v-model="form.receiptContacts" />
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item :label="$t('label_post_code')" prop="receiptPostalCode">
            <ex_super_input v-model="form.receiptPostalCode" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col>
          <el-form-item :label="$t('label_tms_track_receiving_addr')" prop="receiptAddress">
            <el-input type="textarea" v-model="form.receiptAddress" />
          </el-form-item>
        </el-col>
      </el-row>
      <!-- <el-row>
        <el-col>
          <el-form-item :label="$t('label_package_number')" prop="totalQuantity">
            <ex_super_input v-model="form.totalQuantity" />
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item :label="$t('label_volume')" prop="totalVolume">
            <ex_super_input v-model="form.totalVolume" append="m³" />
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item :label="$t('label_weight')" prop="totalWeight">
            <ex_super_input v-model="form.totalWeight" append="kg" />
          </el-form-item>
        </el-col>
      </el-row> -->
      <el-row>
        <el-col>
          <el-form-item :label="$t('label_logistics')" prop="productId">
            <ex_super_input v-model="form.productId" type="select" class="w_fill" :url="$url['fms/ExpressProduct']"
              :option="{ label: 'productName', value: 'productId' }" @changeItem="productChange" />
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item :label="$t('label_payment_method')" prop="payType">
            <ex_super_input v-model="form.payType" class="w_fill" type="select" enum="TmsOrderPayTypeEnum" />
          </el-form-item>
        </el-col>

      </el-row>

      <el-row>

        <el-col>
          <el-form-item :label="$t('label_delivery_type')" prop="deliveryType">
            <ex_super_input v-model="form.deliveryType" @change="autoSetOrder" class="w_fill" type="select"
                            enum="DeliveryTypeEnum" />
          </el-form-item>
        </el-col>
        <el-col v-if="form.deliveryType === 'DELIVERY'">
          <el-form-item :label="$t('label_logistics_company')" prop="selfDeliveryLogisticsName">
            <ex_super_input v-model="form.selfDeliveryLogisticsName" class="w_fill" />
          </el-form-item>
        </el-col>

        <el-col>
          <el-form-item :label="$t('label_delivery_method')" prop="lastTransportType">
            <ex_super_input v-model="form.lastTransportType" class="w_fill" type="select"
                            enum="TmsLastTransportTypeEnum" />
          </el-form-item>
        </el-col>

      </el-row>


      <el-row>

        <el-col>
          <el-form-item :label="$t('label_whether_refund_taxes')" prop="isDrawback">
            <ex_super_input v-model="form.isDrawback" class="w_fill" type="select" enum="YesOrNoEnum" />
          </el-form-item>
        </el-col>

        <el-col>
          <el-form-item :label="$t('label_network_isInsurance')" prop="isInsurance">
            <ex_super_input v-model="form.isInsurance" class="w_fill" type="select" enum="YesOrNoEnum" />
          </el-form-item>
        </el-col>
        <!-- <el-col>
          <el-form-item :label="$t('label_mail_goods')" prop="skuName">
            <ex_super_input v-model="form.skuName" class="w_fill" />
          </el-form-item>
        </el-col> -->
        <el-col>
          <el-form-item :label="$t('label_total_value')">
            <ex_super_input v-model="form.skuAmount" class="w_fill" />
          </el-form-item>
        </el-col>

      </el-row>
      <el-row>

        <!-- <el-col v-else>
          <el-form-item :label="$t('label_collection_time')" prop="collectExpectTime">
            <ex_super_input v-model="form.collectExpectTime" class="w_fill" type= 'date-picker'  attrs=" { type: 'datetimerange' }, keyExtra: { _emitKey: 'input', 0: 'collectExpectTimeStart', 1: 'collectExpectTimeEnd' }"/>
          </el-form-item>
        </el-col> -->
      </el-row>
      <el-row>
        <!-- <el-col>
          <el-form-item :label="$t('label_value_added')" prop="serviceCodeList">
            <ex_super_input v-model="form.serviceCodeList" multiple class="w_fill" type="select"
              enum="DeliveryTypeEnum" />
          </el-form-item>
        </el-col> -->

        <el-col>
          <el-form-item :label="$t('label_remark')">
            <el-input type="textarea" v-model="form.remark" />
          </el-form-item>
        </el-col>
      </el-row>

      <ex_header_spiler :title="$t('label_container_details')"></ex_header_spiler>
      <el-form-item>
        <el-button @click="orderDetailsAdd" size="mini" type="primary">
          {{ $tt('label_base_add') }}
        </el-button>
        <button_select_file @input="selectFile" :disabled="loading" :loading="loading">
          {{ $t('label_import_container_details') }}
          <i class="el-icon-upload2 el-icon--right"></i>
        </button_select_file>
        <el-button @click="downloadImportTemp" size="mini">
          {{ $tt('label_download_import_template') }}<i class="el-icon-download el-icon--right"></i>
        </el-button>
      </el-form-item>
      <el-row>
        <el-col style="width: 100%;">
          <el-form-item class="w_fill" prop="orderDetails" :label="$t('label_container_details')">
            <el-form :model="form" ref="containerForm" :rules="containerRules">
              <ex_super_table v-bind="containerDetailsOption" :data="form.orderDetails" ref="containerDetailsRef" />
            </el-form>

          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="3">
          <el-form-item class="w_fill " prop="omsFiles">
            <template v-slot:label>
              {{ $t('label_attachment_info') }}
              <!-- <select_file_temp service="OMS" module="INBOUND_ATTACHMENT" :label="$t('label_attached_template')" /> -->
            </template>
            <!--            <div style="background-color: rgba(0, 0, 0, 0.02);padding: 10px;margin-bottom: 10px;" class="color_info">-->
            <!--              若有补充的文件，则可在此处上传。-->
            <!--            </div>-->
            <ex-upload-file ref="fileUpload" :value="form.omsFiles" type="upload-file" key="omsFiles" multiple :limit="5"
              drag accept='.xls,.xlsx,.doc,.docx' @input="fileUploadChange">
              <i class="el-icon-upload"></i>
              <div class="el-upload__text" v-html="$t('tip_upload_attachment_drag_click')"></div>
            </ex-upload-file>
          </el-form-item>
        </el-col>
      </el-row>

    </el-form>
  </div>
    <div class="page_rela_bottom_area">
      <template v-if="onlySave">
        <el-button type="primary" @click="submit('SAVE_AUDIT')">{{ $t('label_submit_and_audit') }}</el-button>
      </template>
      <template v-else>
        <el-button @click="submit('SAVE')">{{ $t('label_save_to_draft') }}</el-button>
        <el-button type="primary" @click="submit('SAVE_AUDIT')">{{ $t('label_submit_and_audit') }}</el-button>
      </template>
      <el-button @click="return_page_back">{{ $t('label_cancel') }}</el-button>
    </div>

  </div>
</template>
<script>
import quick_select_customer_address from '@/component/oms/quick_select_customer_address'

import cascader_address_select from '@/component/tms/cascader_address_select'

let _default_form = {
  id: null,
  deliveryCountryCode: '',
  deliveryCountryName: '',
  deliveryProvinceName: '',
  deliveryCityName: '',
  deliveryAreaName: '',
  deliveryAddress: '',
  deliveryUserName: '',
  deliveryContacts: '',
  deliveryPostalCode: '',
  receiptCountryCode: '',
  receiptCountryName: '',
  receiptProvinceName: '',
  receiptCityName: '',
  receiptAreaName: '',
  receiptAddress: '',
  receiptUserName: '',
  receiptContacts: '',
  receiptPostalCode: '',
  totalQuantity: '',
  totalVolume: '',
  totalWeight: '',
  productId: '',
  lastTransportType: 'DOOR_TO_DOOR',
  isDrawback: 'N',
  isInsurance: 'N',
  deliveryType: 'COLLECT',
  serviceCodeList: [],
  payType: 'SENDER_CASH',
  remark: '',
  status: 'DRAFT',
  skuName: '',
  skuAmount: 0,
  omsFiles: [],
  orderDetails: [],
  selfDeliveryLogisticsName: '',
  trackNumber: ''
}
import router_params from '@/mixin/router_params';
import role_system_mixin from '@/mixin/role_system_mixin';

import select_file_temp from '@/component/base/select_file_temp'

import ExcelJS from '@/asset/exceljs.bare.min.js'

export default {
  components: { select_file_temp, cascader_address_select, quick_select_customer_address },
  mixins: [router_params, role_system_mixin],

  data() {
    return {
      isHideReceipt: false,
      isHideDelivery: false,
      edit: false,
      loading: false,
      rules: {
        deliveryCountryCode: [{ required: true, message: this.$t('tip_can_no_empty'), trigger: 'blur' }],
        receiptCountryCode: [{ required: true, message: this.$t('tip_can_no_empty'), trigger: 'blur' }],
        deliveryUserName: [{ required: true, message: this.$t('tip_can_no_empty'), trigger: 'blur' }],
        deliveryContacts: [{ required: true, message: this.$t('tip_can_no_empty'), trigger: 'blur' }],
        deliveryAddress: [{ required: true, message: this.$t('tip_can_no_empty'), trigger: 'blur' }],
        deliveryPostalCode: [{ required: true, message: this.$t('tip_can_no_empty'), trigger: 'blur' }],

        receiptUserName: [{ required: true, message: this.$t('tip_can_no_empty'), trigger: 'blur' }],
        receiptContacts: [{ required: true, message: this.$t('tip_can_no_empty'), trigger: 'blur' }],
        receiptAddress: [{ required: true, message: this.$t('tip_can_no_empty'), trigger: 'blur' }],
        receiptPostalCode: [{ required: true, message: this.$t('tip_can_no_empty'), trigger: 'blur' }],
        totalQuantity: [{ required: true, message: this.$t('tip_can_no_empty'), trigger: 'blur' }],
        totalVolume: [{ required: true, message: this.$t('tip_can_no_empty'), trigger: 'blur' }],
        totalWeight: [{ required: true, message: this.$t('tip_can_no_empty'), trigger: 'blur' }],
        productId: [{ required: true, message: this.$t('tip_can_no_empty'), trigger: 'blur' }],
        payType: [{ required: true, message: this.$t('tip_can_no_empty'), trigger: 'blur' }],
        deliveryType: [{ required: true, message: this.$t('tip_can_no_empty'), trigger: 'blur' }],
        lastTransportType: [{ required: true, message: this.$t('tip_can_no_empty'), trigger: 'blur' }],
        skuName: [{ required: true, message: this.$t('tip_can_no_empty'), trigger: 'blur' }],
        skuAmount: [{ required: true, message: this.$t('tip_can_no_empty'), trigger: 'blur' }],
        selfDeliveryLogisticsName: [{ required: true, message: this.$t('tip_can_no_empty'), trigger: 'blur' }],
        orderDetails: [
          {
            required: true, trigger: 'blur', type: "array", min: 1,
            message: this.$t('tip_please_add_least_one_sku'),
          }, {
            trigger: 'blur', type: "array",
            validator: (r, v, cb) => {
              console
              if (this.form.orderDetails.length === 0) {
                return cb(this.$t("tip_some_box_can_no_have_some_sku"))
              }
              cb()
            }
          }, {
            trigger: 'blur', type: "array",
            validator: (r, v, cb) => {
              if (this.IsHasPALLET && v.some(it => _.isEmpty(it.palletNo))) {
                return cb(this.$t(["label_pallet_code", "tip_can_no_empty"]))
              }
              cb()
            }
          },

        ],

      },
      form: _.cloneDeep(_default_form),
      containerDetailsOption: {
        model: [
          {
            key: 'transportNumber',
            label: 'label_packagea_or_container_or_tracking_code',
            'show-overflow-tooltip': true,
            render: (h, { column, row, index }) => {
              if (row.edit && this.form.deliveryType === 'DELIVERY') {
                return (
                  <el-form-item
                    prop={`orderDetails.${index}.${column.property}`}
                    rules={this.containerRules[column.property]}
                  >
                    <ex_super_input
                      value={row.transportNumber}
                      onInput={value => {
                        this.$set(row, column.property, value)
                      }}
                    >
                    </ex_super_input>
                  </el-form-item>
                )
              } else {
                return (
                  <span>{row.transportNumber}</span>
                )
              }

            }
          },
          {
            key: 'weight', label: 'label_weight_unit', 'show-overflow-tooltip': true,
            render: (h, { column, row, index }) => {
              if (row.edit) {
                return (
                  <el-form-item
                    prop={`orderDetails.${index}.${column.property}`}
                    rules={this.containerRules[column.property]}
                  >
                    <ex_super_input
                      value={row.weight}
                      onInput={value => {
                        this.$set(row, column.property, value)
                      }}
                    >
                    </ex_super_input>
                  </el-form-item>
                )
              } else {
                return (
                  <span>{row.weight}</span>
                )
              }

            }
          },
          {
            key: 'length', label: 'label_length_unit', 'show-overflow-tooltip': true,
            render: (h, { column, row, index }) => {
              if (row.edit) {
                return (
                  <el-form-item
                    prop={`orderDetails.${index}.${column.property}`}
                    rules={this.containerRules[column.property]}
                  >
                    <ex_super_input
                      value={row.length}
                      onInput={value => {
                        this.$set(row, column.property, value)
                      }}
                    >
                    </ex_super_input>
                  </el-form-item>
                )
              } else {
                return (
                  <span>{row.length}</span>
                )
              }

            }
          },
          {
            key: 'width', label: 'label_width_unit', 'show-overflow-tooltip': true,
            render: (h, { column, row, index }) => {
              if (row.edit) {
                return (
                  <el-form-item
                    prop={`orderDetails.${index}.${column.property}`}
                    rules={this.containerRules[column.property]}
                  >
                    <ex_super_input
                      value={row.width}
                      onInput={value => {
                        this.$set(row, column.property, value)
                      }}
                    >
                    </ex_super_input>
                  </el-form-item>
                )
              } else {
                return (
                  <span>{row.width}</span>
                )
              }
            }
          },
          {
            key: 'height', label: 'label_height_unit', 'show-overflow-tooltip': true,

            render: (h, { column, row, index }) => {
              if (row.edit) {
                return (
                  <el-form-item
                    prop={`orderDetails.${index}.${column.property}`}
                    rules={this.containerRules[column.property]}
                  >
                    <ex_super_input
                      value={row.height}
                      onInput={value => {
                        this.$set(row, column.property, value)
                      }}
                    >
                    </ex_super_input>
                  </el-form-item>
                )
              } else {
                return (
                  <span>{row.height}</span>
                )
              }
            }
          },
          {
            type: 'operate', width: 170, operate: [
              {
                label: "label_edit",
                click: (row) => this.clickEdit(row),
                if: (row) => !row.edit
              },
              {
                label: "label_save",
                click: (row) => this.clickEditSave(row),
                if: (row) => row.edit
              },
              {
                label: "label_remove", class: "button_text_danger",
                click: (row, i) => this.removeBox(i)
              },
            ]
          }
        ],
      },
      containerRules: {
        'transportNumber': [{ required: true, message: this.$t('tip_can_no_empty'), trigger: 'blur' },],
        'weight': [{ required: true, message: this.$t('tip_can_no_empty'), trigger: 'blur' },],
        'length': [{ required: true, message: this.$t('tip_can_no_empty'), trigger: 'blur' },],
        'width': [{ required: true, message: this.$t('tip_can_no_empty'), trigger: 'blur' },],
        'height': [{ required: true, message: this.$t('tip_can_no_empty'), trigger: 'blur' },]
      }
    };
  },
  computed: {

    onlySave() {
      return !['DRAFT', 'AUDIT_REJECT'].some(it => it == this.form.status)
    },
  },

  methods: {
    clickEdit(row) {
      this.$set(row, 'edit', true)
    },
    clickEditSave(row) {
      this.$refs['containerForm'].validate((valid, obj) => {
        if (valid) {
          this.$set(row, 'edit', false)
        }
      })
    },
    removeBox(index) {
      this.form.orderDetails.splice(index, 1)
      this.autoSetOrder()
    },

    init_data_default(into_params) {
      this.form = _.cloneDeep(_default_form)

      let { copy, emitKey, title, ...params } = into_params
      this.edit = JSON.parse(into_params.edit)
      if (this.edit || copy) {
        this.form.id = into_params.id
        this.$ajax({
          url: this.$url['oms/OmsExpressdetail'],
          method: 'post',
          loading: { text: this.$t('tip_searching'), target: "#page_order_create" },
          data: params,
          success: (res) => {
            Object.assign(this.form, res.data)
            this.fixTabLabel()
          }
        })
      } else if (!this.form.id) {
        this.$ajax({
          url: this.$url['oms/ExpressGenerateOrder'],
          method: 'get',
          loading: { text: this.$t('tip_searching'), target: "#page_order_create" },
          success: (res) => {
            this.form.trackNumber = res.data
          }
        })

      }

      this.fixTabLabel()
    },
    fixTabLabel() {
      if (this.edit) {
        this.$emit("tagModifyLabel", {
          _key: 'label_name_code',
          name: this.$t("title_edit_packet_order"),
          code: this.form.id || ""
        })
      } else {
        this.$emit('tagModifyLabel', "title_add_packet_order",)
      }
    },
    fileUploadChange(flies) {
      flies.map((item, index) => {
        item.sort = index
      })
      this.form.omsFiles = [...flies]
    },
    submit(opEnum) {
      if (this.$clickFast()) return
      this.$refs['form'].validate((valid, obj) => {
      console.log(obj)
        if (valid) {
          this.submitNet(opEnum)
        } else {
          this.$message.error(this.$t('form_validate_error'))
          return false;
        }
      });
    },
    submitNet(opEnum) {

      let url = ''
      switch (opEnum) {
        case "SAVE_AUDIT":
          //提交并审核
          url = this.$url['oms/ExpressSaveAudit']
          break;
        case "SAVE":
          //保存为草稿
          url = this.$url['oms/ExpressSave']
          break;
      }
      this.$ajax({
        url,
        type: 'json',
        method: 'post',
        data: this.form,
        loading: true,
        success: (res) => {
          this.$message.success(this.$t('tip_submit_success'))
          this.return_emit('packetOrder=>manage', "reload")
          this.form.id = res.data
          if (opEnum === 'SAVE_AUDIT') {
            this.$tag.tagClose(null, this.intoPath)
          }
        },

      })
    },

    uploadSkuFile(cfg) {
      this.$uploadFile({
        loading: true,
        url: this.$url['oms/inboundOrderImportSku'],
        file: cfg.file,
        headers: {
          customerCode: this.form.customerCode
        },
        success: (res) => {
          if (res && res.data && res.data.rows) {
            this.form.omsFiles.push(...res.data.rows)
          }
        },
      })

    },
    selectFile(e) {
      if (!e || e.length == 0) return
      this.form.orderDetails = []
      const keys = ['transportNumber', 'weight', 'length', 'width', 'height']
      let reader = new FileReader();
      reader.onload = (e) => {
        const data = e.target.result
        console.log(e.target.result)

        new ExcelJS.Workbook().xlsx.load(data).then(workbook => {
          const worksheet = workbook.getWorksheet(1);
          const list = []
          worksheet.eachRow((row, rowNumber) => {
            if (rowNumber == 1) return
            console.log(row.values)
            const out = { edit: false }

            keys.forEach((key, index) => {
              out[key] = row.values[index + 1]
            })

            this.form.orderDetails.push(out)

            if (!_.isEmpty(out)) {
              list.push(Object.assign(out, { mapStatus: "ready", }))
            }
          });
          this.$forceUpdate()
          if (list.length == 0) return this.$message.error("导入无数据")


        })
      };
      reader.readAsArrayBuffer(e[0]);
    },
    productChange(item) {
      this.form.productCode = item.productCode
      this.form.productName = item.productName
    },
    // 下载模版
    downloadImportTemp() {
      const wb = new ExcelJS.Workbook()
      const worksheet = wb.addWorksheet(this.$tt('label_container_details'))
      worksheet.columns = this.containerDetailsOption.model.filter(item => item.key).map(it => {
        return { header: this.$tt(it.label), key: it.key, width: it.width }
      });

      wb.xlsx.writeBuffer().then(buffer => {
        this.$downloadBuffer({
          buffer,
          type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
          filename: `${this.$tt('label_container_details')}${new Date().getTime()}.xlsx`,
        })
      })
    },
    orderDetailsAdd() {
      this.form.orderDetails.push({
        transportNumber: '',
        weight: '',
        length: '',
        width: '',
        height: '',
        edit: true
      })
      this.autoSetOrder()
    },
    autoSetOrder() {
      if (this.form.deliveryType === 'COLLECT') {
        if (this.form.orderDetails.length === 1) {
          this.$set(this.form.orderDetails[0], 'transportNumber', `${this.form.trackNumber}`)
        } else {
          this.form.orderDetails.forEach((item, index) => {
            this.$set(item, 'transportNumber', `${this.form.trackNumber}-${index + 1}`)
          })
        }

      }

    },
    deliveryAddressSet(item) {
      console.log(item)
      this.form.deliveryCountryCode = item.countryCode
      this.form.deliveryCountryName = item.countryName
      this.form.deliveryProvinceName = item.province
      this.form.deliveryCityName = item.city
      this.form.deliveryAreaName = item.county
      this.form.deliveryPostalCode = item.postalCode
      this.form.deliveryAddress = item.addressDetail

      this.form.deliveryUserName = item.contacts
      this.form.deliveryContacts = item.contactNumber



      this.isHideDelivery = true
      setTimeout(() => {
        this.isHideDelivery = false
      }, 10);
    },
    receiptAddressSet(item) {
      this.form.receiptCountryCode = item.countryCode
      this.form.receiptCountryName = item.countryName
      this.form.receiptProvinceName = item.province
      this.form.receiptCityName = item.city
      this.form.receiptAreaName = item.county
      this.form.receiptPostalCode = item.postalCode
      this.form.receiptAddress = item.addressDetail

      this.form.receiptUserName = item.contacts
      this.form.receiptContacts = item.contactNumber



      this.isHideReceipt = true
      setTimeout(() => {
        this.isHideReceipt = false
      }, 10);
    },
  }
};

</script>
<style scoped lang="less">


.widthSet{
  width: 100% !important;
  /deep/.el-button{
      width: 100% !important;
    }
}
</style>
